//
//  SetStore.m
//  NewPro
//
//  Created by RYX on 2019/4/26.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "SetStore.h"

@implementation SetStore

#pragma mark - 修改密码
- (void)changePassWordWithCustomId:(NSString *)customId andOldpassword:(NSString *)oldpassword andNewpassword:(NSString *)newpassword andRePassWord:(NSString *)rePassWord Success:(void(^)(void))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/updatePassword",IP];
    
    NSDictionary *dic = @{
                          @"customId":customId,
                          @"oldpassword":oldpassword,
                          @"newpassword":newpassword,
                          @"rePassWord":rePassWord
                          };
    
    [HttpTool postUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        
        if (error == nil) {
            
            success();
        }else{
            
            failure(error);
        }
        
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}

#pragma mark - 设置支付密码
- (void)setTradingPassWordWithSecret:(NSString *)secret andValidateCode:(NSString *)validateCode Success:(void(^)(void))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/wallet/payPass",IP];
    
    NSDictionary *dic = @{
                          @"secret":secret,
                          @"validateCode":validateCode
                          };
    
    [HttpTool postUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        if (error == nil) {
            
            success();
        }else{
            
            failure(error);
        }
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}

#pragma mark - 更改手机号码---------
#pragma mark - 验证登录密码
- (void)judgeLoginPassWithPassword:(NSString *)password Success:(void(^)(void))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/info/auth",IP];
    
    NSDictionary *dic = @{
                          @"password":password
                          };
    
    [HttpTool postUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        if (error == nil) {
            
            success();
        }else{
            
            failure(error);
        }
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}

#pragma mark - 更换新手机
- (void)changePhoneNumWithNewPhone:(NSString *)newPhone code:(NSString *)code Success:(void(^)(void))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/info/changePhone",IP];
    
    NSDictionary *dic = @{
                          @"content":newPhone,
                          @"validateCode":code
                          };
    
    [HttpTool putUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        if (error == nil) {
            
            success();
        }else{
            
            failure(error);
        }
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}

@end
